﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public enum Specialty
{
    CST,
    IT,
    Maths,
    Informatic,
    Physics,
    Law
}

public enum University
{
    SU,
    TU,
    UNNS,
    NBU
}

public enum Faculty
{
    FKSU,
    FMI,
    EF,
    FTK,
    ETF
}

class Student : ICloneable, IComparable<Student>
{
    public string FirstName { get; set; }
    public string SecondName { get; set; }
    public string LastName { get; set; }
    public int SocSecNumber { get; set; }
    public string Address { get; set; }
    public string MobilePhone { get; set; }
    public string EMail { get; set; }
    public int Cource { get; set; }
    public Specialty Specialty { get; set; }
    public University University { get; set; }
    public Faculty Faculty { get; set; }

    public Student(string firstName, string secondName, string lastName, int SSN, string address,
                      string mobilePhone, string eMail, int cource, Specialty specialty, University university, Faculty faculty)
    {
        FirstName = firstName;
        SecondName = secondName;
        LastName = lastName;
        SocSecNumber = SSN;
        Address = address;
        MobilePhone = mobilePhone;
        EMail = eMail;
        Cource = cource;
        Specialty = specialty;
        University = university;
        Faculty = faculty;
    }

    public Student()
    {
        FirstName = "Bai";
        SecondName = "Ivan";
        LastName = "Piqnicata";
        SocSecNumber = -1;
        Address = "any street";
        MobilePhone = "not available";
        EMail = "wtf";
        Cource = -1;
        Specialty = Specialty.Informatic;
        University = University.TU;
        Faculty = Faculty.FKSU;
    }

    public override bool Equals(object obj)
    {
        Student student = obj as Student;
        if (student == null)
        {
            return false;
        }
        if (!String.Equals(this.FirstName + this.SecondName + this.LastName,
                            student.FirstName + student.SecondName + student.LastName))
        {
            return false;
        }
        if (!String.Equals(this.SocSecNumber,student.SocSecNumber))
        {
            return false;
        }
        if (!String.Equals(this.Address,student.Address))
        {
            return false;
        }
        if (!String.Equals(this.MobilePhone,student.MobilePhone))
        {
            return false;
        }

        if (!String.Equals(this.EMail, student.EMail))
        {
            return false;
        }
        if (this.Cource != student.Cource)
        {
            return false;
        }
        if (!this.Specialty.Equals(student.Specialty))
        {
            return false;
        }
        if (!this.University.Equals(student.University))
        {
            return false;
        }
        if (!this.Faculty.Equals(student.Faculty))
        {
            return false;
        }
        return true;
    }

    public override string ToString()
    {
        StringBuilder result = new StringBuilder("Names: ");
        if (this.FirstName != null)
        {
            result.Append(this.FirstName + " ");
        }
        if (this.SecondName != null)
        {
            result.Append(this.SecondName + " ");
        }
        if (this.LastName != null)
        {
            result.Append(this.LastName);
        }
        
        result.Append("; \nSocial Security Number: ");
        result.Append(this.SocSecNumber);
        
        result.Append("; \nAddress: ");
        if (this.Address!= null)
        {
            result.Append(this.Address);
        }

        result.Append("; \nPhone: ");
        if (this.MobilePhone != null)
        {
            result.Append(this.MobilePhone);
        }

        result.Append("; \ne-mail: ");
        if (this.EMail != null)
        {
            result.Append(this.EMail);
        }

        result.Append(String.Format("; \nCource: {0}", this.Cource));

        result.Append(String.Format("; \nSpecialty: {0}", this.Specialty));

        result.Append(String.Format("; \nUniversity: {0}", this.University));

        result.Append(String.Format("; \nFaulty: {0}", this.Faculty));
        
        return result.ToString();
    }

    public override int GetHashCode()
    {
        return FirstName.GetHashCode() ^ SecondName.GetHashCode() ^ LastName.GetHashCode() ^
                 SocSecNumber.GetHashCode() ^ Address.GetHashCode() ^ MobilePhone.GetHashCode() ^
                 EMail.GetHashCode() ^ Cource.GetHashCode() ^ Specialty.GetHashCode() ^
                 University.GetHashCode() ^ Faculty.GetHashCode();
    }

    public static bool operator ==(Student student1, Student student2)
    {
        return Student.ReferenceEquals(student1, student2);
    }

    public static bool operator !=(Student student1, Student student2)
    {
        return !Student.ReferenceEquals(student1, student2);
    }


    public object Clone()
    {
        Student result = new Student();
        result.FirstName = FirstName;
        result.SecondName = SecondName;
        result.LastName = LastName;
        result.SocSecNumber = SocSecNumber;
        result.Address = Address;
        result.MobilePhone = MobilePhone;
        result.EMail = EMail;
        result.Cource = Cource;
        result.Specialty = Specialty;
        result.University = University;
        result.Faculty = Faculty;
        return result;
    }

    public int CompareTo(Student other)
    {
        if (other == null)
        {
            throw new NullReferenceException();
        }
        else
        {
            if (FirstName.Equals(other.FirstName))
            {
                if (SocSecNumber == other.SocSecNumber)
                {
                    return 0;
                }
                else
                {
                    if (SocSecNumber < other.SocSecNumber)
                    {
                        return -1;
                    }
                    else
                    {
                        return 1;
                    }
                }
            }
            else
            {
                return FirstName.CompareTo(other.FirstName);
            }
        }
    }
}

